This is a trap handler of the sort you might use if you were programming the ST in 68000 assembler, or you were using a high level language and needed to write a binding for access to a BIOS, XBIOS or GEMDOS function. The functions assume the C calling conventions, that is, if there are any parameters, they are assumed to have been pushed onto the stack in reverse order, and to be no smaller than a word (16 bits). The number of the routine itself must be pushed last, just before the trap call. Of course if you are developing using the C provided in Atari's kit for developers, this process will be transparent to you, since a set of bindings is available which makes TOS calls look just like ordinary C function calls.
; At entry, any arguments for the function have been pushed on the stack
; in reverse order, C-style. Then the function number was pushed.
; Finally this routine was called, so as we enter the return address of
; the caller is on top of the stack.
retsv: ds.l ; some memory for a long variable
traprtn:
move.l (a7)+, retsv ; Save off the return address,
; because the OS functions don't
; expect it.
trap #13 ; Trap to the BIOS function. (BIOS
; is available through trap 13,
; XBIOS through 14, GEMDOS through
; trap 1).
move.l retsv, -(a7) ; Put the return address back on
; stack.
rts ; Return to caller.
********** Example 3 **********
/* SAMPLE.C Original version provided by Atari as part of the developer's
kit. Rearranged, cleaned up, defines added, many variable names changed,
and all comments added by M.R.
*/
/* This program is a simple example of use of some VDI primitives and certain
parts of the AES, in particular the window library and the event handler.
It opens a window on the desktop and draws a filled ellipse in it. It waits
for the user to move the window or resize it, and then redraws the ellipse.
If the user selects the window close box, the program closes the window
and then terminates.
*/
/* Defines. These are all just for readibility. */
#define COLOR0 0
#define COLOR1 1
#define SCREEN 1
#define SOLID 1
#define PATTERN 2
#define USER 4
#define DOT 1
#define SYSTEM 1
#define RC 2
#define ARROW 0
#define WORKAREA 4
#define WNAME 2
#define WINDAREA 1
#define CLIPON 1
#define WM_REDRAW 20
#define WM_CLOSED 22
#define WM_SIZED 27
#define WM_MOVED 28
#define WF_CURRXYWH 5
/* Window type bits */
#define NAME 0x0001
#define CLOSE 0x0002
#define MOVE 0x0008
#define SIZE 0x0020
/* These arrays are used by the VDI in its own code. The developer is
expected to allocate room for them somewhere in the application. */
int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256];
main()
{
/* Local variables */
/* For the workstation */
int workin[10]; /* Input values for v_openvwk() */
int workout[56]; /* Ouput values for v_openvwk() */
int shandle; /* Workstation (screen) handle */
/* Variables for our application's window */
int whandle; /* Window handle */
int wind_type; /* Holds window attribute bits */
int xwork; /* X coordinate, upper left hand corner,
work area of window */
int ywork; /* Y coordinate, upper left hand corner,
work area of window */
int wwork; /* Width, work area of window */
int hwork; /* Height, work area of window */
int xbord; /* X coordinate, upper left hand corner,
border of window */
int ybord; /* Y coordinate, upper left hand corner,
border of window */
int wbord; /* Width, border area of window */
int hbord; /* Height, border area of window */
int xcen, ycen; /* Coordinates of central point in window */
/* These four variables are returned by graf_handle() (described
later). They are not used further in this application. */
int gr_wchar, gr_hchar; /* Width and height of a character cell
for font used in menus and dialogs */
int gr_wbox, gr_hbox; /* Width and height of box large enough
to hold a system font character */
/* Miscellaneous */
int ap_id; /* Application id */
int clip[4]; /* Holds coordinates defining clip region */
int mgbuf[8]; /* Buffer for message events from AES */
int dummy; /* Word buffer for miscellaneous use */
/* Begin program */
/* Appl_init is the AES initialization routine. It makes the AES
aware of the application, and initializes certain AES data
structures. The application id it returns can be used later by
the application for other AES routines. */
ap_id = appl_init();
/* When the application starts, GEM has already opened the screen
workstation for its own use. Therefore the screen has a workstation
handle (identifier). We need this handle to open our own virtual
workstation with the attributes we would like. The routine
graf_handle (part of the AES graphics library) returns this handle.
It also puts certain character size info into the passed parameters